package com.itheima.homework;

import com.itheima.homework.domain.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class HomeworkDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> clazz = Class.forName("com.itheima.homework.domain.Student");
        Constructor<?> constructor = clazz.getDeclaredConstructor();
        Student student = (Student) constructor.newInstance();
        System.out.println(student);
        Constructor<?> constructor1 = clazz.getDeclaredConstructor(String.class, int.class);
        constructor1.setAccessible(true);
        Student student1 = (Student) constructor1.newInstance("张三", 23);
        System.out.println(student1);
    }
}
